package cn.hibernatedemo.biz;

import cn.hibernatedemo.dao.HibernateUtil;
import cn.hibernatedemo.dao.ProjectDao;
import cn.hibernatedemo.entity.Project;
import org.hibernate.Transaction;

public class ProjectBiz {

    private ProjectDao projectDao=new ProjectDao();

    public void addProject(Project project){
        Transaction tx=null;
        try {
          tx = HibernateUtil.currentSession().beginTransaction();
          projectDao.save(project);
          tx.commit();
        }catch (Exception e){
            e.printStackTrace();
            if(tx!=null){
                tx.rollback();
            }
        }
    }
}
